package com.Stream流.Test;

import java.util.ArrayList;
import java.util.stream.Stream;

public class StreamDemo {
    public static void main(String[] args) {
        //创建集合
        ArrayList<String> manlist = new ArrayList<String>();
        manlist.add("周润发");
        manlist.add("成龙");
        manlist.add("刘德华");
        manlist.add("吴京");
        manlist.add("周星驰");
        manlist.add("李连杰");

        ArrayList<String> womanlist = new ArrayList<String>();
        womanlist.add("林心如");
        womanlist.add("张曼玉");
        womanlist.add("林青霞");
        womanlist.add("柳岩");
        womanlist.add("林志玲");
        womanlist.add("王祖贤");

        //男演员只要名字3个字的前三人
        Stream<String> manStream = manlist.stream().filter(s -> s.length() == 3).limit(3);

        //女演员只要姓林的，并且不要第一个
        Stream<String> womanStream = womanlist.stream().filter(s -> s.startsWith("林")).skip(1);

        //把过滤后的男演员和女演员姓名结合在一起
        Stream<String> stream = Stream.concat(manStream, womanStream);

        //把上一步操作后的元素作为构造方法的参数创建演员对象，遍历数据
//        stream.map(Actor::new).forEach(System.out::println);
        stream.map(Actor::new).forEach(p -> System.out.println(p.getName()));

    }
}
